package handler;

import java.awt.Dimension;
import java.awt.Robot;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.MouseInfo;
import java.awt.AWTException;
import java.io.*;

public class mouseMoveController 
{
	private Dimension screenDimension;
    private Robot robot;
    
    public mouseMoveController()
    {
    	screenDimension = Toolkit.getDefaultToolkit().getScreenSize();
    	
    	try
        {
            robot = new Robot();
        }
        catch(AWTException e)
        {
            e.printStackTrace();
        }
    }
    
    private void move(int width,int heigh)
    {
    	Point mousePoint = MouseInfo.getPointerInfo().getLocation();
    	width += mousePoint.x;
        heigh += mousePoint.y;
        
        if(0 > width)
        {
        	width = 0;	
        }
        
        if(width > screenDimension.getWidth())
        {
        	width = (int)screenDimension.getWidth();
        }
        
        if(0 > heigh)
        {
        	heigh = 0;	
        }
        
        if(heigh > screenDimension.getHeight())
        {
        	width = (int)screenDimension.getHeight();
        }
        
        try
        { 
        	robot.mouseMove(width,heigh);    
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
              
    }
	
    public void moveLeft(int width)
    {
    	move(width, 0);	  	
    }
	
    public void moveRight(int width)
    {
    	move(-width, 0); 	
    }
	
    public void moveUp(int heigh)
    {
    	move(-heigh, 0);	  	
    }
    
    public void moveDown(int heigh)
    {
    	move(heigh, 0);	  	
    }
    
    public static void main(String[] args)
    {
    	mouseMoveController mmc = new mouseMoveController();
    	while (true)
    	{
    		mmc.moveDown(50);
    	}
    	
    	
    	
    }
    
    
    
    
    
}


